package cn.iocoder.yudao.module.dine.config.controller.app;

import cn.iocoder.yudao.framework.business.basic.annotation.AppJsonView;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.api.dine.vo.DineConfigVO;
import cn.iocoder.yudao.module.dine.config.convert.DineConfigConvert;
import cn.iocoder.yudao.module.dine.config.pojo.po.DineConfig;
import cn.iocoder.yudao.module.dine.config.service.core.CoreDineConfigService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 前端控制器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/08/01
 */
@Tag(name = "用户 APP - 点餐配置")
@RestController
@RequestMapping("/dine/config")
public class AppDineConfigController {
    @Resource
    private CoreDineConfigService coreDineConfigService;

    @GetMapping("/get")
    @Operation(summary = "获取配置")
    @Parameter(name = "shopId", description = "店铺编号", example = "1")
    @JsonView(AppJsonView.class)
    @PermitAll
    public CommonResult<DineConfigVO> getDetail(@RequestParam("shopId") Long shopId) {
        DineConfig config = coreDineConfigService.getOrCreate(shopId);
        return CommonResult.success(DineConfigConvert.INSTANCE.toViewObject(config));
    }

}
